package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.system.domain.TCfTermination;
import com.ruoyi.system.service.ITCfTerminationService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;

/**
 * 【请填写功能名称】Controller
 *
 * @author wish
 * @date 2021-06-18
 */
@RestController
@RequestMapping("/termination")
public class TCfTerminationController extends BaseController {
    @Autowired
    private ITCfTerminationService tCfTerminationService;


    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize(hasPermi = "system:termination:list")
    @GetMapping("/list")
    public TableDataInfo list(TCfTermination tCfTermination) {
        startPage();
        List<TCfTermination> list = tCfTerminationService.selectTCfTerminationList(tCfTermination);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize(hasPermi = "system:termination:export")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TCfTermination tCfTermination) throws IOException {
        List<TCfTermination> list = tCfTerminationService.selectTCfTerminationList(tCfTermination);
        ExcelUtil<TCfTermination> util = new ExcelUtil<TCfTermination>(TCfTermination.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize(hasPermi = "system:termination:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(tCfTerminationService.selectTCfTerminationById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PreAuthorize(hasPermi = "system:termination:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TCfTermination tCfTermination) {
        return toAjax(tCfTerminationService.insertTCfTermination(tCfTermination));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize(hasPermi = "system:termination:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TCfTermination tCfTermination) {
        return toAjax(tCfTerminationService.updateTCfTermination(tCfTermination));
    }


 /*   @PreAuthorize(hasPermi = "system:termination:upload")
    @PostMapping("upload")
    public R upload(@RequestParam("file")MultipartFile file) throws Exception {
        String uploadFile = iSysFileService.uploadFile(file);
        //R upload = upload(file);
        return R.ok(uploadFile);
    }*/
}
